package com.bw.lib_log.logger

import android.util.Log
import com.bw.lib_log.LoggerLevel

class NetLogger: ILogger {
    private var isDebug = true
    private var level = LoggerLevel.DEBUG
    private var TAG = ""
    private var path = ""
    private var loggerFormat = "===>$TAG %s --->%s" //格式化，%s 占位符

    override fun v(tag: String, log: String) {
        if (isDebug && level.value <= LoggerLevel.VERBOSE.value){
            Log.v(TAG, "输入到文件"+String.format(loggerFormat, tag, log))
        }
    }

    override fun d(tag: String, log: String) {
        if (isDebug && level.value <= LoggerLevel.DEBUG.value){
            Log.d(TAG, "输入到文件"+String.format(loggerFormat, tag, log))
        }
    }

    override fun i(tag: String, log: String) {
        if (isDebug && level.value <= LoggerLevel.INFO.value){
            Log.i(TAG, "输入到文件"+String.format(loggerFormat, tag, log))
        }
    }

    override fun w(tag: String, log: String) {
        if (isDebug && level.value <= LoggerLevel.WARN.value){
            Log.w(TAG, "输入到文件"+String.format(loggerFormat, tag, log))
        }
    }

    override fun e(tag: String, log: String) {
        if (isDebug && level.value <= LoggerLevel.ERROR.value){
            Log.e(TAG, "输入到文件"+String.format(loggerFormat, tag, log))
        }
    }

    override fun setDebug(isDebug: Boolean) {
        this.isDebug = isDebug
    }

    override fun setLevel(level: LoggerLevel) {
        this.level = level
    }

    override fun setTag(tag: String) {
        this.TAG = tag
    }

    override fun setSavaUrl(path: String) {
        this.path = path
    }

}